package org.example.student_dormitory.service.impl;

import org.example.student_dormitory.dao.AdminDao;
import org.example.student_dormitory.dao.impl.AdminDaoImpl;
import org.example.student_dormitory.dto.Result;
import org.example.student_dormitory.entity.Admin;
import org.example.student_dormitory.service.AdminService;

//管理员的业务逻辑层

public class AdminServiceImpl implements AdminService {
    private AdminDao adminDao = new AdminDaoImpl();
    // 管理员登陆操作
    @Override
    public Result<Admin> login(String username, String password, int dr) {
//        System.out.println("进入Service");

        Admin admin = adminDao.selectByAdmin(username,password,dr);
        Result<Admin> result = new Result<>();
        if (admin != null) {
            result.setCode(200);
            result.setMsg("登陆成功");
            result.setData(admin);
            return result;
        }else {
            result.setCode(100);
            result.setMsg("账号或密码错误");
            result.setData(null);
//            System.out.println("登陆失败");
            return result;
        }
    }
}
